package com.gzz.manage.sys.request;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.gzz.common.base.BaseDao;

/**
 * @类说明 【请求时长统计】数据访问层
 * @author 高振中
 * @date 2021-02-20 14:02:55
 **/
@Repository
//@Slf4j
public class RequestDao extends BaseDao {

	/**
	 * @方法说明 【请求时长统计】列表
	 */
	public List<Request> list(RequestCond cond) {
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT t.path,t.appName,t.sumCount,t.sumMilliSecond,t.avgMilliSecond,t.maxMilliSecond,t.minMilliSecond,t.type");
		sql.append(" FROM sys_request t");
		sql.append(cond.where());
		sql.append(" ORDER BY path DESC");
		return list(sql.toString(), cond, Request.class);
	}

	/**
	 * @方法说明 【请求时长统计】批量插入
	 */
	public int[] insertBatch(List<Request> list) {
		StringBuilder sql = new StringBuilder();
		sql.append("REPLACE INTO sys_request (path,appName,sumCount,sumMilliSecond,avgMilliSecond,maxMilliSecond,minMilliSecond,type)");
		sql.append(" VALUES (:path,:appName,:sumCount,:sumMilliSecond,:avgMilliSecond,:maxMilliSecond,:minMilliSecond,:type)");
		return batchOperate(list, sql.toString());
	}

}